import os, os.path
from django.core.management.base import BaseCommand, CommandError

from market.baseSaver import saveRoomToFiles


##################################################################################################
# this command take the object in base and create associated text file.
# the data saved are those which will allow to reconstruct the base in the same state (except histories and comments)
class Command(BaseCommand):
    help = 'save the base in the specified directory'

    def handle(self, *args, **options):
    
        mypath = os.getcwd()
        if len( args )> 0:
            mypath = args[0]
        mypath = mypath + '\savedRoomFiles'
        if not os.path.isdir(mypath):
            os.makedirs(mypath)

        saveRoomToFiles( mypath )
        return
